package utility

import (
	"github.com/gomodule/redigo/redis"
)

var redisPool *redis.Pool


func RedisPollInit() *redis.Pool {


	db := redis.DialDatabase(11)
	return &redis.Pool{
		MaxIdle:   3,
		MaxActive: 5,
		Dial: func() (redis.Conn, error) {
			c, err := redis.Dial("tcp", "xxxx:6379",db)
			if err != nil {
				return nil, err
			}

			//_, err = c.Do("AUTH", "")
			//if err != nil {
			//	c.Close()
			//	return nil, err
			//}
			return c, err
		},
	}
}


func GetRedisConn()(redis.Conn) {

	redisPool = RedisPollInit()

	return redisPool.Get()
}